/*
 * Alexey Danchuk
 * This software is an implementation of the task from OOP module.
 */
package input;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import static parser.Parser.QUESTION_REPRESENTATION;

/**
 * This class describes basics issues about manual question input.
 *
 * @version 2.03 20 February 2013
 * @author Alexey Danchuk
 */
public class ManualInput extends Input {

    private String[] inputFromUser;

    @Override
    public void input() throws Exception {
        createQuestions();
        System.out.println("Input your data: (type 'quit' to exit) ");
        for (int index = 0; index < getInputFromUser().length; index++) {
            BufferedReader inputStream = new BufferedReader(
                    new InputStreamReader(System.in));
            inputFromUser[index] = inputStream.readLine();
        }
    }

    private int height() {
        Scanner sc = new Scanner(System.in);
        System.out.println("How many questions?");
        while (!sc.hasNextInt()) {
            System.out.println("Integer only, please!");
            sc.next();
        }
        final int questionNumber = sc.nextInt();
        return questionNumber;
    }

    private void createQuestions() {
        int size = height();
        inputFromUser = new String[size * QUESTION_REPRESENTATION];
    }
    
    /**
     * @return the inputFromUser
     */
    public String[] getInputFromUser() {
        return inputFromUser;
    }
}
